// @ts-nocheck
/**
 * @Date: 2022-03-10 20:15:46
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-03-14 09:19:41
 * @FilePath: \zhihuReal\routes\comment.js
 * @Description: 评论路由
 */
const router = require('koa-router')()
router.prefix('/questions/:questionId/answers/:answerId/comments')
const {
    auth
} = require('../middlewares/auth')
//控制器
const {
    commentList,
    oneComment,
    createComment,
    updateComment,
    removeComment,
} = require('../controllers/commentCtl')
const {
    cheackCommentExist,
    cheackCommentOwner
} = require('../middlewares/cheack')
//获取评论列表
router.get('/', commentList)
//获取单个评论
router.get('/:id', cheackCommentExist, oneComment)
//创建评论
router.post('/', auth, createComment)
//更新评论
router.patch('/:id', auth, cheackCommentExist, cheackCommentOwner, updateComment)
//删除评论
router.delete('/:id', auth, cheackCommentExist, cheackCommentOwner, removeComment)
module.exports = router